Skip to content

fix(h265): add bounds safety in mpeg4 codec parsing and remove dead code#2191

Open
MechanicalCoderX wants to merge 1 commit intoAlexxIT:masterfrom
MechanicalCoderX:fix/h265-bounds-safety
Open

fix(h265): add bounds safety in mpeg4 codec parsing and remove dead code#2191
MechanicalCoderX wants to merge 1 commit intoAlexxIT:masterfrom
MechanicalCoderX:fix/h265-bounds-safety

Conversation

@MechanicalCoderX
Copy link
Copy Markdown

DecodeConfig: add a minimum 28-byte length check before accessing conf[1:4] and conf[23:], plus per-section length guards before slicing each VPS/SPS/PPS region — a truncated HEVCDecoderConfigurationRecord previously caused an index-out-of-range panic.

EncodeConfig: return nil early when vps/pps are empty or sps is shorter than 6 bytes; the existing code copied sps[3:6] unconditionally.

RTPDepay: remove the dead check if nuStart > len(buf)+4. nuStart is assigned from len(buf) before appending, so after at least 6 bytes are appended the condition is always false and the buf[:0] reset never fired.

DecodeConfig: add a minimum 28-byte length check before accessing
conf[1:4] and conf[23:], plus per-section length guards before slicing
each VPS/SPS/PPS region — a truncated HEVCDecoderConfigurationRecord
previously caused an index-out-of-range panic.

EncodeConfig: return nil early when vps/pps are empty or sps is shorter
than 6 bytes; the existing code copied sps[3:6] unconditionally.

rtp.go RTPDepay: remove the dead check `if nuStart > len(buf)+4`.
nuStart is assigned from len(buf) before appending, so after at least
6 bytes are appended the condition is structurally always false and the
buf[:0] reset that followed it never fired.  The size field is written
correctly by the PutUint32 on the next line regardless.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant